package io.kiki.stack.http.feign.moshi;

import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;

public class MoshiFactory {
    private MoshiFactory() {
    }

    /**
     * Registers JsonAdapter by implicit type. Adds one to read numbers in a {@code Map<String,
     * Object>} as Integers.
     */
    static Moshi create(Iterable<JsonAdapter<?>> adapters) {
        Moshi.Builder builder = new Moshi.Builder();

        for (JsonAdapter<?> adapter : adapters) {
            builder.add(adapter.getClass(), adapter);
        }

        return builder.build();
    }
}
